package com.woniu.project.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.project.core.domain.ManagementRole;
import com.woniu.project.core.domain.RolePermission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Klaus
 * @since 2020-10-13
 */
public interface RolePermissionMapper extends BaseMapper<RolePermission> {

    /**
     * 根据角色ID查询所有这个角色所拥有的权限ID
     * @param roleId
     * @return
     */
    @Select("select role_permission_id,role_id\n" +
            ",permission_id from \n" +
            "pawn_role_permission where role_id = #{roleId}")
    List<RolePermission> selectPermissionByRoleId(Integer roleId);

    @Delete("delete from pawn_role_permission where role_id = #{RoleId} and permission_id = #{PermissionId}")
    void deletePermissionByRoleIdAndPermissionId(@Param("RoleId") Integer RoleId,@Param("PermissionId") Integer PermissionId);

}
